package com.manager.common.quartz;

import org.quartz.Job;

public abstract class JobEntity {

    public String jobName;

    public String aliasName;

    public Class<? extends Job> jobClass;

    public Object jobParams;


    public String getJobName() {
        return jobName;
    }

    public void setJobName(String jobName) {
        this.jobName = jobName;
    }

    public String getAliasName() {
        return aliasName;
    }

    public void setAliasName(String aliasName) {
        this.aliasName = aliasName;
    }

    public Class<? extends Job> getJobClass() {
        return jobClass;
    }

    public void setJobClass(Class<? extends Job> jobClass) {
        this.jobClass = jobClass;
    }

    public Object getJobParams() {
        return jobParams;
    }

    public void setJobParams(Object jobParams) {
        this.jobParams = jobParams;
    }

    public final boolean start(){
       try {
           QuartzManager.getInstance().addJob(this);
           return true;
       }catch (Exception e){
           e.printStackTrace();
       }
       return false;
    }
    public final boolean destroy(){
        try {
            QuartzManager.getInstance().deleteJob(jobName);
            return true;
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }
    public final boolean pause(){
        try {
            QuartzManager.getInstance().pauseJob(jobName);
            return true;
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }
    public final boolean resume(){
        try {
            QuartzManager.getInstance().resumeJob(jobName);
            return true;
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }
}
